#include "stdafx.h"
#include "SingleVent.h"
const double SillSingleVent = 0; // the sill of a single vent is always zero
#include <iostream>
using namespace std;
SingleVent::SingleVent()
{
}
SingleVent::SingleVent(const double& value):
m_VentCoe(value)
{
    validate(); 
}
SingleVent::SingleVent(const SingleVent& rhs):
m_VentCoe(rhs.m_VentCoe)
{
	validate();
}
SingleVent::~SingleVent()
{
	// do nothing
}
SingleVent& SingleVent::operator =(const SingleVent& rhs)
{
	if ( this != &rhs)
	{
        m_VentCoe = rhs.m_VentCoe;
		validate();
	}
	return *this;
}
const double& SingleVent::VentCoe() const
{
	return m_VentCoe;
}
void SingleVent::VentCoe(const double& value)
{
	 m_VentCoe = value;
	 validate();
}
/*double SingleVent::output(const double& sill)
{
	return calc(sill);
}*/

double SingleVent::calc(const double& sill) const
{
	return (threshold(sill, SillSingleVent)*m_VentCoe);

}
SingleVent* SingleVent::clone() const
{
	return new SingleVent(*this);
}
bool SingleVent::check() const
{
	if ((m_VentCoe >= 0) && (m_VentCoe <= 1))
		return true;
	return false;
}

void SingleVent::validate() const
{
	if (check())
        return;
	else
	{
		cout << "Program terminated.  Coefficents of single vents fall in inappropriate range." << endl;
		exit(1);
	}
}